package com.yc.dao;

import com.yc.bean.DinnerTableBean;
import com.yc.commons.DBHelper;

import java.util.List;

public class DinnerTableDao extends DBHelper {
    static DBHelper db = new DBHelper();

    public static List<DinnerTableBean> find() {
        String sql ="select * from tb_dinner_table where disabled = 0 ";
        try {
           return  db.select(DinnerTableBean.class,sql);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    public static Boolean occupancy(int tableid){
        String sql="UPDATE tb_dinner_table\n" +
                "SET table_status = 1\n" +
                "WHERE id=?; ";
        int i = db.doUpdate(sql, tableid);
        if (i>0){
            return true;
        }else {
            return false;
        }

    }

    public static Boolean release(int tableid){
        String sql="UPDATE tb_dinner_table\n" +
                "SET table_status = 0\n" +
                "WHERE id=?; ";
        int i = db.doUpdate(sql, tableid);
        if (i>0){
            return true;
        }else {
            return false;
        }

    }
}
